<?php
/**
 * Yii view _service_tab
 *
 * @author nguyenmanhluu
 * @since Jul 26, 2013 - 4:00:43 PM
 */
?>
<link type="text/css" rel="stylesheet" href="<?php echo $this->assetDir ?>css/kdt/service.css" />

<div class="row-fluid">
    <div id="list_service" class="span12">
        <div class="table-responsive"> 
            <table class="table table-bordered table-striped table-condensed">
                <thead>
                    <tr>
                        <th></th>
                        <th>Name</th>
                        <?php if (Yii::app()->controller->isAdmin): ?>                        
                            <th>Merchant</th>
                        <?php endif; ?>
                        <th>Category</th>
                        <th>Duration</th>
                        <th class="text-right">Price</th>
                        <th class="text-right">Points</th>
                        <th class="text-center">Book Online</th>                                          
                        <th></th>                                          
                    </tr>
                </thead>   
                <tbody>
                    <?php if ($services): ?>
                        <?php foreach ($services as $item): ?>
                            <tr data="<?php $item->sid ?>">
                                <td class="text-center">
                                    <img class="thumb_on_list" 
                                         src="<?php echo $item->publicAvatar ?>" />
                                </td>
                                <td class="center modify-name"><?php echo $item->s_name ?></td>
                                <?php if (Yii::app()->controller->isAdmin): ?>
                                    <td class="center">
                                        <?php
                                        if ($item->user != null)
                                        {
                                            echo $item->user->name;
                                        }
                                        ?>
                                    </td>
                                <?php endif; ?>
                                <?php if ($item->category): ?>
                                    <td class="center">
                                        <?php echo $item->category->name ?>
                                    </td>
                                <?php else: ?>
                                    <td class="center">&npnb;</td>
                                <?php endif; ?>
                                <td class="center">
                                    <?php echo $item->durationTime ?>
                                </td>
                                <td class="center text-right">
                                    $<?php echo $item->priceFormat ?>
                                </td>
                                <td class="center text-right">
                                    <?php
                                    if ($item->user != null)
                                    {
                                        if ($item->user->service != null)
                                        {
                                            echo $item->price * $item->user->service->money_to_points;
                                        }
                                    }
                                    ?>
                                </td>
                                <td class="center text-center">
                                    <?php if ($item->book_online == 1): ?>
                                        <i class="icon-ok"></i>
                                    <?php endif; ?>
                                </td>
                                <td class="center modify-td">
                                    <a href="<?php
                                    echo Yii::app()->createUrl('service/update', array(
                                        'id' => $item->sid,
                                    ));
                                    ?>" class="btn btn-info">
                                        <i class="icon-edit "></i>                                            
                                    </a>
                                    <!--                                <a onclick="return deleteService($(this));" class="btn btn-danger" 
                                                                       href="<?php echo $item->deleteUrl ?>">
                                                                        <i class="icon-trash "></i> 
                                                                    </a>-->
                                </td>                                       
                            </tr>                             
                        <?php endforeach; ?>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
    <div id="form_service_add" class="span6" style="min-height:200px; display:none">
        <?php $this->renderPartial('_service_form', array('model' => $service_model)); ?>
    </div>
    <div id="form_service_edit" class="span6" style="min-height:200px; display:none"></div>
</div>        
<script src="<?php echo $this->assetDir ?>js/kdt/service.js"></script>